Closed
Bug 1387035
Opened 8 years ago
Closed 8 years ago
./mach clang-format - use python/mozversioncontrol for hg/git detection
Categories
(Developer Infrastructure :: Source Code Analysis, enhancement)
Developer Infrastructure
Source Code Analysis
Tracking
(firefox57 fixed)
RESOLVED
FIXED
mozilla57
Tracking | Status | |
---|---|---|
firefox57 | --- | fixed |
People
(Reporter: Sylvestre, Assigned: dex, Mentored)
References
Details
(Keywords: good-first-bug, Whiteboard: [good first bug][lang=python])
Attachments
(1 file)
Comment from gps in bug 1376803:
"Also, if you write version control code, consider sticking it in python/mozversioncontrol. Not a blocker. But a nice to have so we don't reinvent as many wheels."
Reporter | ||
Updated•8 years ago
|
Assignee | ||
Comment 1•8 years ago
|
||
Hi Sylvestre, I would like to work on this.
Reporter | ||
Comment 2•8 years ago
|
||
sure, please give it a try!
Comment hidden (mozreview-request) |
Reporter | ||
Updated•8 years ago
|
Attachment #8897597 -
Flags: review?(sledru) → review?(gps)
Reporter | ||
Comment 4•8 years ago
|
||
gps is the pro for this, redirecting to him the review.
Comment 5•8 years ago
|
||
mozreview-review |
Comment on attachment 8897597 [details]
Bug 1387035 - Update clang-format methods to use mozversioncontrol for hg/git detection
https://reviewboard.mozilla.org/r/168872/#review174238
::: tools/mach_commands.py:265
(Diff revision 1)
> def run_clang_format_diff(self, clang_format_diff, show):
> # Run clang-format on the diff
> # Note that this will potentially miss a lot things
> from subprocess import Popen, PIPE
>
> - if os.path.exists(".hg"):
> + repository = mozversioncontrol.get_repository_object(self.topsrcdir)
Use ``self.repository``.
::: tools/mach_commands.py:267
(Diff revision 1)
> diff_process = Popen(["hg", "diff", "-U0", "-r", ".^",
> "--include", "glob:**.c", "--include", "glob:**.cpp",
> "--include", "glob:**.h",
> "--exclude", "listfile:.clang-format-ignore"], stdout=PIPE)
> else:
> git_process = Popen(["git", "diff", "--no-color", "-U0", "HEAD^"], stdout=PIPE)
> try:
> diff_process = Popen(["filterdiff", "--include=*.h",
Ideally these pieces would be abstracted and exposed as a method on the repository object. But that's a bit of scope bloat. The change as-is is better than it was before.
::: tools/mach_commands.py:340
(Diff revision 1)
>
> # Run clang-format
> cf_process = Popen(args)
> if show:
> # show the diff
> - if os.path.exists(".hg"):
> + repository = mozversioncontrol.get_repository_object(self.topsrcdir)
Use ``self.repository``.
Attachment #8897597 -
Flags: review?(gps) → review-
Assignee | ||
Comment 6•8 years ago
|
||
(In reply to Gregory Szorc [:gps] from comment #5)
> ::: tools/mach_commands.py:267
> (Diff revision 1)
> > diff_process = Popen(["hg", "diff", "-U0", "-r", ".^",
> > "--include", "glob:**.c", "--include", "glob:**.cpp",
> > "--include", "glob:**.h",
> > "--exclude", "listfile:.clang-format-ignore"], stdout=PIPE)
> > else:
> > git_process = Popen(["git", "diff", "--no-color", "-U0", "HEAD^"], stdout=PIPE)
> > try:
> > diff_process = Popen(["filterdiff", "--include=*.h",
>
> Ideally these pieces would be abstracted and exposed as a method on the
> repository object. But that's a bit of scope bloat. The change as-is is
> better than it was before.
>
I can also do that change, but I need some advise about the what the method signature should look like.
All current methods of mozversioncontrol Repository class are returning full output string, never a PIPE, so I was thinking to introduce:
def get_changes_to_format(self, pipe=False):
"""Return diffs of modified files that needs to be formatted.
:param pipe: if True return a Popen pipe, else the output string.
"""
Are you ok with that ?
Reporter | ||
Comment 7•8 years ago
|
||
mozreview-review |
Comment on attachment 8897597 [details]
Bug 1387035 - Update clang-format methods to use mozversioncontrol for hg/git detection
https://reviewboard.mozilla.org/r/168872/#review174498
::: tools/mach_commands.py:274
(Diff revision 1)
> "--include", "glob:**.h",
> "--exclude", "listfile:.clang-format-ignore"], stdout=PIPE)
> else:
> git_process = Popen(["git", "diff", "--no-color", "-U0", "HEAD^"], stdout=PIPE)
> try:
> diff_process = Popen(["filterdiff", "--include=*.h",
This code has been removed in bug 1387036
please update your code!
thanks
Comment hidden (mozreview-request) |
Comment 9•8 years ago
|
||
mozreview-review |
Comment on attachment 8897597 [details]
Bug 1387035 - Update clang-format methods to use mozversioncontrol for hg/git detection
https://reviewboard.mozilla.org/r/168872/#review174720
Attachment #8897597 -
Flags: review?(gps) → review+
Comment 10•8 years ago
|
||
Pushed by sledru@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/0828f347805f
Update clang-format methods to use mozversioncontrol for hg/git detection r=gps
Comment 11•8 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Reporter | ||
Updated•8 years ago
|
Attachment #8897597 -
Flags: review?(sledru)
Updated•7 years ago
|
Product: Core → Firefox Build System
Updated•3 years ago
|
Product: Firefox Build System → Developer Infrastructure
You need to log in
before you can comment on or make changes to this bug.
Description
•